/*
*	Project: Aethon
*
*	File: Control.cpp
*
*	Author: Jonathan Hersack
*
*	Date: 2/15/2009
*
*   Purpose: The Control handles the keyboard/mouse input for the 
*   user-to-model interaction
*/

#include "../include/Control2.h"
//singleton pattern based on http://www.inquiry.com/techtips/cpp_pro/10min/10min0200.asp
	Control2* Control2::pinstance = 0;// initialize pointer	

	Control2* Control2::getInstanceOf()//returns instance of Control2
	{
		if (pinstance == 0)  // is it the first call?
		{  
		pinstance = new Control2; // create sole instance
		}
		return pinstance; // address of sole instance
	}//end get instance of
	
	
	//#############################################################
	void Control2::keyboardHandle(unsigned char key, int x, int y)
    {//use unit vector model.direction to increment velocity in correct direction
	//by using a differential velocity passed to updateVelocity
	//v[2] is forward look vector, v[1] is upward vector, v0 is strafe vector
	
	Control2 *theControl2 = Control2::getInstanceOf();
	
	
switch(key)
   {    
   case '`': //regiters stage handler's keyboard function
   case '~': theControl2->setIsActive(!theControl2->getIsActive());
   *(theControl2->getHandleNumberPtr())=1;//tells director to check for active control handler
   glutPostRedisplay();
             break;
}//end switch

	
    }//end keyboardhandle

	
